import { Component, Input, OnInit } from '@angular/core';

import { Product } from '../app/Product';
import { ProductService } from '../app/ProductService';

@Component({
  selector: 'app-product-list',
  templateUrl: './product-list.component.html',
  styleUrls: ['./product-list.component.less'],
  providers: [ProductService]
})
export class ProductListComponent implements OnInit {
  @Input() title: string | undefined
  products: Array<Product> = []

  constructor(private productService: ProductService) {}

  ngOnInit() {
    this.products = this.productService.getProducts()
  }

  share() {
    window.alert('The product has been shared!');
  }

  onNotify() {
    window.alert('You will be notified when the product goes on sale');
  }
}
